﻿//内部页面弹出层
var msgBox={	
		"id":"",
		"mainId":"#msgbox",
		"maskId":"#mask",
		"fid":"",
		"callback":null,
		"bland":false,
		"cancelCallback":null,
		//"ie6":$.browser.msie && ($.browser.version == '6.0')||false,
		"resize":function(){
			var h=$(window).height();
			var ch=$(this.id).height();
			var height = $('body').height()>$(window).height()? $('body').height():$(window).height();
			$(this.maskId).height(height);
			if(h>ch){
				$(this.mainId).css('top',(h-ch)/2);
			}else{
				$(this.mainId).css('position','absolute');
				$(this.mainId).css('top','0');
			}
			$(this.maskId).height();
			// if(this.ie6){			
			// 	$(this.mainId).css('position','absolute');
			// 	$(this.maskId).height();
			// }
		},
		"showMsgbox":function(id,msg,fid,callback,cancelCallback){
			this.id=id;
			this.fid=fid;
			msgBox.callback= callback;
			msgBox.cancelCallback= cancelCallback;
			$(this.mainId+">div").hide();
			$(this.maskId).css('display','block');
			$(this.mainId).css('display','block');
			$(id).css('display','block');
			if(msg){
				$(id).find('.noteContent').html(msg);
			}
			if(!msgBox.bland){
				this.bindEvent();
			}
			if(id == "#box-success") {
				var mainId = this.mainId;
				var maskId = this.maskId;
				var timer = setTimeout(function() {
					$(mainId).hide();
					$(maskId).hide();	
					clearTimeout(timer);
				}, 2000);
			}		
			this.resize();
		},
		"hideLayout":function(){
			$(this.mainId).hide();
			$(this.maskId).hide();	
			if(this.fid!=''){
				$(this.fid).focus();
			}					
		},	
		"bindEvent":function(){
			var that = msgBox;
			$(this.mainId+" .close ,"+this.mainId+" .btnSure ,"+this.mainId+" .btnCancel").click(function(){
				that.hideLayout();
			});
			$(this.mainId+" .btnSure").click(function(){
				if(msgBox.callback){
					msgBox.callback.call();
				}				
			})
			$(this.mainId+" .btnCancel").click(function(){
				if(msgBox.cancelCallback){
					msgBox.cancelCallback.call();
				}				
			})
			$(window).resize(function(){
				that.resize();
			});
			msgBox.bland=true;
		}
	}; 

